package xwbank.jmeter5.utils;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class MQUtil {
    public  Connection getConnection(String ip, int port, String userName, String password) throws IOException, TimeoutException{
        //1.创建连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //2.在工厂对象中设置连接信息
        factory.setHost(ip);
        factory.setPort(port);
        //mq通过用户来管理
        factory.setUsername(userName);
        factory.setPassword(password);
        //通过工厂对象获取连接
        Connection connection = factory.newConnection();
        return connection;
    }
}
